import * as ol from '../openLayer'
/**
   * 绘制时线条、画笔 的样式
   */
export const drawingLineStyle = (options) => {
  return new ol.Style({ //  线条
    fill: new ol.Fill({
      color: options.lineConfig.drawingStyle.fillColor
    }),
    stroke: new ol.Stroke({
      color: options.lineConfig.drawingStyle.strokeColor,
      lineDash: options.lineConfig.drawingStyle.strokeLineDash,
      width: options.lineConfig.drawingStyle.strokeWidth
    }),
    image: new ol.CircleStyle({ // 画笔
      radius: options.paintBrushConfig.radius,
      stroke: new ol.Stroke({
        color: options.paintBrushConfig.strokeColor
      }),
      fill: new ol.Fill({
        color: options.paintBrushConfig.fillColor
      })
    })
  })
}
/**
   * 绘制结束时线条、画笔 的样式
   */
export const drawEndLineStyle = (options) => {
  return new ol.Style({ //  线条
    fill: new ol.Fill({
      color: options.lineConfig.drawEndStyle.fillColor
    }),
    stroke: new ol.Stroke({
      color: options.lineConfig.drawEndStyle.strokeColor,
      lineDash: options.lineConfig.drawEndStyle.strokeLineDash,
      width: options.lineConfig.drawEndStyle.strokeWidth
    }),
    image: new ol.CircleStyle({ // 画笔
      radius: options.paintBrushConfig.radius,
      stroke: new ol.Stroke({
        color: options.paintBrushConfig.strokeColor
      }),
      fill: new ol.Fill({
        color: options.paintBrushConfig.fillColor
      })
    })
  })
}

/**
* 坐标点提示样式
* @returns
*/
export const pointTipStyle = (options, bool = false) => {
  if (bool) {
    return new ol.Style({
      text: new ol.Text({
        font: options.labelConfig.pointTipStyle.drawEndStyle.textStyle.font,
        fill: new ol.Fill({
          color: options.labelConfig.pointTipStyle.drawEndStyle.textStyle.fillColor
        }),
        backgroundFill: new ol.Fill({
          color: options.labelConfig.pointTipStyle.drawEndStyle.textStyle.backgroundFillColor
        }),
        padding: options.labelConfig.pointTipStyle.drawEndStyle.textStyle.padding,
        textBaseline: options.labelConfig.pointTipStyle.drawEndStyle.textStyle.textBaseline,
        offsetY: options.labelConfig.pointTipStyle.drawEndStyle.textStyle.offsetY
      }),
      image: new ol.RegularShape({
        radius: options.labelConfig.pointTipStyle.drawEndStyle.imageStyle.radius,
        points: options.labelConfig.pointTipStyle.drawEndStyle.imageStyle.points,
        angle: options.labelConfig.pointTipStyle.drawEndStyle.imageStyle.angle,
        displacement: options.labelConfig.pointTipStyle.drawEndStyle.imageStyle.displacement,
        fill: new ol.Fill({
          color: options.labelConfig.pointTipStyle.drawEndStyle.imageStyle.fillColor
        })
      })
    })
  } else {
    return new ol.Style({
      text: new ol.Text({
        font: options.labelConfig.pointTipStyle.drawingStyle.textStyle.font,
        fill: new ol.Fill({
          color: options.labelConfig.pointTipStyle.drawingStyle.textStyle.fillColor
        }),
        backgroundFill: new ol.Fill({
          color: options.labelConfig.pointTipStyle.drawingStyle.textStyle.backgroundFillColor
        }),
        padding: options.labelConfig.pointTipStyle.drawingStyle.textStyle.padding,
        textBaseline: options.labelConfig.pointTipStyle.drawingStyle.textStyle.textBaseline,
        offsetY: options.labelConfig.pointTipStyle.drawingStyle.textStyle.offsetY
      }),
      image: new ol.RegularShape({
        radius: options.labelConfig.pointTipStyle.drawingStyle.imageStyle.radius,
        points: options.labelConfig.pointTipStyle.drawingStyle.imageStyle.points,
        angle: options.labelConfig.pointTipStyle.drawingStyle.imageStyle.angle,
        displacement: options.labelConfig.pointTipStyle.drawingStyle.imageStyle.displacement,
        fill: new ol.Fill({
          color: options.labelConfig.pointTipStyle.drawingStyle.imageStyle.fillColor
        })
      })
    })
  }
}

/**
* 终点坐标点提示样式
* @returns
*/
export const setLabelStyle = (options, bool = false) => {
  if (bool) {
    return new ol.Style({
      text: new ol.Text({
        font: options.labelConfig.labelStyle.drawEndStyle.textStyle.font,
        fill: new ol.Fill({
          color: options.labelConfig.labelStyle.drawEndStyle.textStyle.fillColor
        }),
        backgroundFill: new ol.Fill({
          color: options.labelConfig.labelStyle.drawEndStyle.textStyle.backgroundFillColor
        }),
        padding: options.labelConfig.labelStyle.drawEndStyle.textStyle.padding,
        textBaseline: options.labelConfig.labelStyle.drawEndStyle.textStyle.textBaseline,
        offsetY: options.labelConfig.labelStyle.drawEndStyle.textStyle.offsetY
      }),
      image: new ol.RegularShape({
        radius: options.labelConfig.labelStyle.drawEndStyle.imageStyle.radius,
        points: options.labelConfig.labelStyle.drawEndStyle.imageStyle.points,
        angle: options.labelConfig.labelStyle.drawEndStyle.imageStyle.angle,
        displacement: options.labelConfig.labelStyle.drawEndStyle.imageStyle.displacement,
        fill: new ol.Fill({
          color: options.labelConfig.labelStyle.drawEndStyle.imageStyle.fillColor
        })
      })
    })
  } else {
    return new ol.Style({
      text: new ol.Text({
        font: options.labelConfig.labelStyle.drawingStyle.textStyle.font,
        fill: new ol.Fill({
          color: options.labelConfig.labelStyle.drawingStyle.textStyle.fillColor
        }),
        backgroundFill: new ol.Fill({
          color: options.labelConfig.labelStyle.drawingStyle.textStyle.backgroundFillColor
        }),
        padding: options.labelConfig.labelStyle.drawingStyle.textStyle.padding,
        textBaseline: options.labelConfig.labelStyle.drawingStyle.textStyle.textBaseline,
        offsetY: options.labelConfig.labelStyle.drawingStyle.textStyle.offsetY
      }),
      image: new ol.RegularShape({
        radius: options.labelConfig.labelStyle.drawingStyle.imageStyle.radius,
        points: options.labelConfig.labelStyle.drawingStyle.imageStyle.points,
        angle: options.labelConfig.labelStyle.drawingStyle.imageStyle.angle,
        displacement: options.labelConfig.labelStyle.drawingStyle.imageStyle.displacement,
        fill: new ol.Fill({
          color: options.labelConfig.labelStyle.drawingStyle.imageStyle.fillColor
        })
      })
    })
  }
}

/**
 * 鼠标提示样式
 * @returns
 */
export const setTipStyle = (options) => {
  return new ol.Style({
    text: new ol.Text({
      font: options.mouseTipConfig.textStyle.font,
      fill: new ol.Fill({
        color: options.mouseTipConfig.textStyle.fillColor
      }),
      backgroundFill: new ol.Fill({
        color: options.mouseTipConfig.textStyle.backgroundFillColor
      }),
      padding: options.mouseTipConfig.textStyle.padding,
      textAlign: options.mouseTipConfig.textStyle.textAlign,
      offsetX: options.mouseTipConfig.textStyle.offsetX
    })
  })
}

/**
 * 鼠标提示样式
 * @returns
 */
export const modifyStyle = (options) => {
  return new ol.Style({
    image: new ol.CircleStyle({
      radius: options.paintBrushConfig.radius,
      stroke: new ol.Stroke({
        color: options.paintBrushConfig.strokeColor
      }),
      fill: new ol.Fill({
        color: options.paintBrushConfig.fillColor
      })
    }),
    text: new ol.Text({
      font: options.mouseTipConfig.textStyle.font,
      fill: new ol.Fill({
        color: options.mouseTipConfig.textStyle.fillColor
      }),
      backgroundFill: new ol.Fill({
        color: options.mouseTipConfig.textStyle.backgroundFillColor
      }),
      padding: options.mouseTipConfig.textStyle.padding,
      textAlign: options.mouseTipConfig.textStyle.textAlign,
      offsetX: options.mouseTipConfig.textStyle.offsetX
    })
  })
}
